<template>
  <div>
            <section class="col-md-12">
                <div style="padding: 0;margin-top: 10px;" id="well_sl">
                    <div class="col-md-12 form-group well" style="width: 98%;margin-left: 1%;">
                        <el-col :span="6" style="margin-top: 10px;height: 40px;">
                            <el-form :model="form" label-width="100px" class="demo-ruleForm">
                                <el-form-item label="选择报表类别" clearable prop="typeId">
                                    <el-select v-model="select.now_principal_id" filterable clearable placeholder="请选择"
                                               style="border-radius: 0 5px 5px 0;">
                                        <el-option v-for="item in options1"  :label="item"
                                                   :value="item"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-form>
                        </el-col>
                        <el-col :span="8" style="margin-top: 10px;height: 40px;">
                            <el-form :model="form" label-width="100px" class="demo-ruleForm">
                                <el-form-item label="时间" clearable prop="typeId">
                                    <el-date-picker v-model="select.create_date" type="daterange" clearable align="right"
                                                    unlink-panels range-separator="-" start-placeholder="开始日期"
                                                    end-placeholder="结束日期" :picker-options="pickerOptions2">
                                    </el-date-picker>
                                </el-form-item>
                            </el-form>
                        </el-col>

                        <el-col :span="6" style="margin-top: 10px;height: 40px;">
                            <el-button type="plain" icon="el-icon-setting" class="setting" size="mini">查询</el-button>
                        </el-col>
                    </div>
                </div>
            </section>

    <div class="col-md-12" style="border-top: 1px solid #ccc;border-bottom: 1px solid #ccc;">
      <el-col :span="24">
        <el-tooltip class="item" effect="dark" content="点击按钮，弹出对话框，选择是显示列内容，不选是隐藏下面的对应列内容（对话框是模拟数据）" placement="top">
          <el-popover placement="bottom" width="300" trigger="click">
            <el-col :span="12">
              <el-checkbox v-model="showCustomerCode" @change="showHide('showCustomerCode')">客户代码 </el-checkbox>
            </el-col>
            <el-col :span="12">
              <el-checkbox v-model="showCustomerStatus" @change="showHide('showCustomerStatus')">客户状态 </el-checkbox>
            </el-col>
            <el-col :span="12">
              <el-checkbox v-model="showCustomerCate" @change="showHide('showCustomerCate')">客户类别 </el-checkbox>
            </el-col>
            <el-col :span="12">
              <el-checkbox v-model="showCreditRank" @change="showHide('showCreditRank')">客户信用等级</el-checkbox>
            </el-col>
            <el-col :span="12">
              <el-checkbox v-model="showCreditLine" @change="showHide('showCreditLine')">授信额度</el-checkbox>
            </el-col>
            <el-col :span="12">
              <el-checkbox v-model="showCapital" @change="showHide('showCapital')">注册资金</el-checkbox>
            </el-col>
            <el-col :span="12">
              <el-checkbox v-model="showAnnualSales" @change="showHide('showAnnualSales')">年销售额</el-checkbox>
            </el-col>
            <el-col :span="12">
              <el-checkbox v-model="showBank" @change="showHide('showBank')">对公银行账号</el-checkbox>
            </el-col>
            <el-col :span="12">
              <el-checkbox v-model="showCertificateNo" @change="showHide('showCertificateNo')">开户银行 </el-checkbox>
            </el-col>
            <el-col :span="12">
              <el-checkbox v-model="showAddress" @change="showHide('showAddress')">税务登记证号</el-checkbox>
            </el-col>
            <el-col :span="12">
              <el-checkbox v-model="showArea" @change="showHide('showArea')">地址</el-checkbox>
            </el-col>
            <el-col :span="12">
              <el-checkbox v-model="showBrand" @change="showHide('showBrand')">经营面积</el-checkbox>
            </el-col>
            <el-col :span="12">
              <el-checkbox v-model="showBankAccount" @change="showHide('showBankAccount')">模拟，对应列表的列项</el-checkbox>
            </el-col>
            <el-button size="mini" slot="reference" type="plain" icon="el-icon-setting" class="setting mg-10" style="margin:20px"> 设置显示 </el-button>
          </el-popover>
        </el-tooltip>
        <el-button type="plain" icon="el-icon-setting" class="setting" size="mini">查询</el-button>
        <el-tooltip class="item" effect="dark" content="导出查询的列表" placement="top">
          <el-button  size="small"
                           style="margin-top: 10px;margin-bottom: 10px;float: right" type="plain" class="setting">
            <div style="display: flex;flex-direction: column;"><i class="el-icon-setting"></i><span
                            style="margin-top: 3px">导出</span></div>
          </el-button>
        </el-tooltip>
        <el-button  size="small"
                            style="margin-top: 10px;margin-bottom: 10px;float: right;margin-left:10px" type="plain" class="setting">
          <div style="display: flex;flex-direction: column;"><i class="el-icon-setting"></i><span
                            style="margin-top: 3px">打印</span></div>
        </el-button>
      </el-col>
    </div>
    <div class="col-md-12">
      <el-col :span="24" style="text-align: center"> 采购汇总表 </el-col>
    </div>
    <div class="col-md-12">
      <el-table
                ref="multipleTable"
                :data="tableData"
                show-summary
                border
                stripe
                height="600"
                row-class-name="tableRow"
                header-row-class-name="tableHeader"
                @row-dblclick="handleSelectionChange"
                style="width: 100%;border-top:1px solid #c5c5c5;">
        <el-table-column
                    type="selection"
                    width="55"> </el-table-column>
        <el-table-column
                    prop="id"
                    label="序号"
                    width="50"> </el-table-column>
        <el-table-column
                    prop="date"
                    label="月份"
                    width="150"> </el-table-column>
        <el-table-column
                    prop="date"
                    label="日期"
                    width="150"> </el-table-column>
        <el-table-column
                    prop="date"
                    label="供应商"
                    width="150"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="物品名称"
                    width="120"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="采购单号"
                    width="120"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="成色"
                    width="120"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="颜色"
                    width="120"> </el-table-column>
        </el-table-column>
        <el-table-column
                    prop="name"
                    label="型号"
                    width="120"> </el-table-column>
        </el-table-column>
        <el-table-column
                    prop="name"
                    label="规格"
                    width="120"> </el-table-column>
        </el-table-column>
        <el-table-column
                    prop="name"
                    label="尺寸"
                    width="120"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="数量"
                    width="120"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="重量"
                    width="120"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="折足金料重量"
                    width="120"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="金价"
                    width="120"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="系统单价"
                    width="120"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="采购单价"
                    width="120"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="对足金料重量"
                    width="120"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="足金折现金额"
                    width="120"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="对足金料重量"
                    width="120"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="加工费"
                    width="120"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="总金额"
                    width="120"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="采购员"
                    width="120"> </el-table-column>
        <el-table-column
                    prop="name"
                    label="备注"
                    width="120"> </el-table-column>
      </el-table>
    </div>
    <el-dialog id="customerDialog" title="客户管理" :visible.sync="dialogCostoms" style="display:none;">
      <el-form size="mini" :model="customer" label-width="100px">
        <el-form-item label="姓名" prop="name">
          <el-input v-model="customer.name" auto-complete="off" class="clientName"></el-input>
        </el-form-item>
        <el-form-item label="客户代码">
          <el-input v-model="customer.customercode" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="客户类别" prop="customercate">
          <el-select v-model="customer.customercate" filterable style="width:100%;">
            <el-option v-for="item in crmsclientRank" :label="item.typename"
                                   :value="item.typename"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="客户信用等级" prop="creditrank">
          <el-select v-model="customer.creditrank" filterable style="width:100%;">
            <el-option v-for="item in crmsclientStatic" :label="item.typename"
                                   :value="item.typename"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="授信额度">
          <el-input v-model="customer.creditline" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="注册资金">
          <el-input v-model="customer.capital" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="年销售额">
          <el-input v-model="customer.annualsales" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="对公银行账号">
          <el-input v-model="customer.bankaccount" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="开户银行">
          <el-input v-model="customer.bank" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="税务登记证号">
          <el-input v-model="customer.certificateno" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="地址">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="经营面积">
          <el-input v-model="customer.area" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="授权品牌">
          <el-input v-model="customer.brand" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="注册商标">
          <el-input v-model="customer.trademark" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="网址">
          <el-input v-model="customer.website" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="法人">
          <el-input v-model="customer.lperson" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="法人电话">
          <el-input v-model="customer.lphone" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="业务联系人">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="业务电话">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="业务手机">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="业务微信">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="业务邮箱">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="传真">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="客户来源">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="客户需求">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="本月度订单数">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="本月度采购额">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="本年度订单数">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="本年度采购额">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="客服姓名">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="客服代码">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="录单人">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="customer.address" auto-complete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogCostoms = false">取 消</el-button>
        <el-button type="primary" @click="dialogAdd">确定提交审核</el-button>
      </div>
    </el-dialog>
    <el-dialog id="changeCustomerDialog" title="移交客户" :visible.sync="dialogCostomsChange" style="display:none;">
      <el-form size="mini" :model="customer" label-width="100px">
        <el-form-item label="客户姓名" prop="name">
          <el-input v-model="customer.name" placeholder="选择的客户名称" class="clientName"
                              :disabled="true"></el-input>
        </el-form-item>
        <el-form-item label="客服姓名">
          <el-input v-model="customer.address" placeholder="旧客服" disabled
                              auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="交接客服人员" prop="customercate">
          <el-select v-model="customer.customercate" filterable style="width:100%;">
            <el-option v-for="item in customerstaffs" :label="item.typename"
                                   :value="item.typename"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="交接原因" prop="creditrank">
          <el-select v-model="customer.creditrank" filterable style="width:100%;">
            <el-option v-for="item in changeReason" :label="item.typename"
                                   :value="item.typename"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="name">
          <el-input v-model="customer.name" placeholder="当选择其他必须填写" class="clientName"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogCostomsChange = false">取 消</el-button>
        <el-button type="primary" @click="dialogAdd">确定提交审核</el-button>
      </div>
    </el-dialog>
    <change-customer v-bind:dialogshow="dialogChangeCustomer" @dialog_close="change_customer_dialog_close"></change-customer>
    <send-message v-bind:dialogshow="dialogSendMessage" @dialog_close="send_message_dialog_close"></send-message>
    <send-weixin v-bind:dialogshow="dialogWeixin" @dialog_close="send_weixin_dialog_close"></send-weixin>
    <send-email v-bind:dialogshow="dialogEmail" @dialog_close="send_email_dialog_close"></send-email>
  </div>
</template>
<style>
    .col-md-12 {
        display: block;
        overflow: hidden;
        background-color: #f5f5f5;
    }

    .tableHeader th {
        background-color: #f5f5f5 !important;
        /*color: #000000;*/
        /*border-color: #c5c5c5;*/
    }

    .el-tabs__content {
        padding: 0px !important;
    }

    .ml-10 {
        margin-left: 10px;
    }

    .mg-10 {
        margin: 10px;
    }

    .mr-10 {
        margin-right: 10px;
    }

    #customerDialog .el-dialog__body .el-form-item {
        width: 45%;
        float: left;
        margin-bottom: 5px;
    }

    #customerDialog .el-dialog__body .el-form-item:nth-child(odd) {
        float: right;
    }

    #customerDialog .el-dialog__footer {
        clear: both;
    }

    .tableRow {
        cursor: pointer;
    }
</style>
<script>
  module.exports = {
    methods: {
      handleClick (row) {
        console.log(row)
      },
      handleSelectionChange (val) {
        //显示弹框
        console.log(333)
        this.dialogCostoms = true
      },

      openChangeCustomerDialog (val) {
        this.dialogCostomsChange = true
      },

      handleDelCustomer(val){
        // 删除操作
        this.$confirm('此操作将永久删除该记录, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消操作'
          });
        });

      },

      handleImport(val){
        if (val === 1) {
          //导入操作
          this.$alert('打开文件夹导入工作', '导入', {
            confirmButtonText: '确定',
            callback: action => {
              this.$message({
                type: 'success',
                message: '导入成功'
              });
            }
          });
        }else{
          //导出操作
          this.$alert('打开文件夹导出工作', '导出', {
            confirmButtonText: '确定',
            callback: action => {
              this.$message({
                type: 'success',
                message: '导出表格成功'
              });
            }
          });
        }
      },

      handleButtons(val){
        switch(val){
          case 1:
            this.dialogSendMessage = 'true'
            console.log(this.dialogSendMessage)
            break;
          case 2:
            this.dialogWeixin = 'true'
            console.log(this.dialogWeixin)
            break;
          case 3:
            this.dialogEmail = 'true'
            console.log(this.dialogEmail)
            break;
          case 4:
            this.dialogChangeCustomer = 'true'
            console.log(this.dialogChangeCustomer)
            break;
          case 6:
            this.$confirm('是否继续操作?', '提示', {
              confirmButtonText: '确定',
              cancelButtonText: '取消',
              type: 'warning'
            }).then(() => {
              this.$message({
                type: 'success',
                message: '操作成功!'
              })
            }).catch(() => {
              this.$message({
                type: 'info',
                message: '已取消'
              })
            })
            break;
        }

      },
      handleChangeCustomer(val){
        this.dialogChangeCustomer = 'true'
        console.log(this.dialogChangeCustomer)
      },
      dialogAdd () {
        console.log(123)
      },
      getSummaries (param) {
        const { columns, data } = param
        const sums = []
        columns.forEach((column, index) => {
          if (index === 0) {
            sums[index] = '总价'
            return
          }
          const values = data.map(item => Number(item[column.property]))
          if (!values.every(value => isNaN(value))) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr)
              if (!isNaN(value)) {
                return prev + curr
              } else {
                return prev
              }
            }, 0)
            sums[index] += ' 元'
          } else {
            sums[index] = ''
          }
        })

        return sums
      },
      showHide (text) {
        console.log(text)
      },
      send_message_dialog_close(val){
        console.log(val)
        this.dialogSendMessage = false
      },
      send_weixin_dialog_close(val){
        this.dialogWeixin = false
      },
      send_email_dialog_close(val){
        this.dialogEmail = false
      },
      change_customer_dialog_close(val){
        console.log(val)
        this.dialogChangeCustomer = false
      }
    },

    data () {
      return {

        dialogCostoms: false,
        dialogCostomsChange: false,
        dialogSendMessage:false,
        dialogWeixin:false,
        dialogEmail:false,
        dialogChangeCustomer:false,     //客户跟进
        customer: {
          name: '',
          customercode: '',
          customerstatus: '',
          customercate: '',
          creditrank: '',
          creditline: '',
          capital: '',
          annualsales: '',
          bank: '',
          certificateno: '',
          address: '',
          area: '',
          brand: '',
          bankaccount: '',
          trademark: '',
          website: '',
          lperson: '',
          lphone: '',
          contacts: '',

          phone: '',
          phonenum: '',
          weixin: '',
          email: '',
          fax: '',
          resource: '',
          requirement: '',
          ordercountmonth: '',
          purchaseamountmonth: '',
          ordercountyear: '',
          purchaseamountyear: '',
          customerstaffname: '',
          customerstaffcode: '',
          operator: '',
          insertime: '',
          remark: '',
        },

        form: {
          typeId: ''
        },

        select: {
          name: '',
          introduce: '',
          cooperative_brand: '',
          customer_status: '',
          customer_level: '',
          now_principal_id: '',
          last_follow_up_date: '',
          create_date: '',
        },

        crmsclientStatic: [
          { typename: 'A级' },
          { typename: 'B级' },
          { typename: 'C级' },
          { typename: 'D级' },
        ],

        crmsclientRank: [
          { typename: 'A类' },
          { typename: 'B类' },
          { typename: 'C类' },
          { typename: 'D类' },
        ],

        customerstaffs: [
          { typename: '客服1' },
          { typename: '客服2' },
          { typename: '客服3' },
          { typename: '客服4' },
        ],

        changeReason: [
          { typename: '交接原因一' },
          { typename: '交接原因二' },
          { typename: '交接原因三' },
          { typename: '其他' },
        ],

        options1: [
          '采购汇总表',
          '采购对账表',
          '采购汇总表',
          '采购付款计划汇总表',
          '采购现结汇总表',
          '采购月结比例表',
          '采购退货统计表',
          '采购品质合格率',
          '采购交期达成汇总表',
          '采购交期达成率',
          '采购溢价汇总表',
          '采购降价汇总表',
          '采购性价优化率',
        ],

        pickerOptions2: {
          shortcuts: [{
            text: '最近一周',
            onClick (picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
              picker.$emit('pick', [start, end])
            }
          }, {
            text: '最近一个月',
            onClick (picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
              picker.$emit('pick', [start, end])
            }
          }, {
            text: '最近三个月',
            onClick (picker) {
              const end = new Date()
              const start = new Date()
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
              picker.$emit('pick', [start, end])
            }
          }]
        },  //日期控件
        pickerOptions1: {
          disabledDate (time) {
            return time.getTime() > Date.now()
          },
          shortcuts: [{
            text: '今天',
            onClick (picker) {
              picker.$emit('pick', new Date())
            }
          }, {
            text: '昨天',
            onClick (picker) {
              const date = new Date()
              date.setTime(date.getTime() - 3600 * 1000 * 24)
              picker.$emit('pick', date)
            }
          }, {
            text: '一周前',
            onClick (picker) {
              const date = new Date()
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
              picker.$emit('pick', date)
            }
          }]
        }, //首次合作日期

        showCustomerCode: true,
        showCustomerStatus: true,
        showCustomerCate: true,
        showCreditRank: true,
        showCreditLine: true,
        showCapital: true,
        showAnnualSales: true,
        showBank: true,
        showCertificateNo: true,
        showAddress: true,
        showArea: true,
        showBrand: true,
        showBankAccount: true,
        showTrademark: true,
        showWebsite: true,
        showLperson: true,
        showLphone: true,
        showContacts: true,

        showPhone: true,
        showPhoneNum: true,
        showWeixin: true,
        showEmail: true,
        showFax: true,
        showResource: true,
        showRequirement: true,
        showOrderCountMonth: true,
        showPurchaseAmountMonth: true,
        showOrderCountYear: true,
        showPurchaseAmountYear: true,
        showCustomerStaffName: true,
        showCustomerStaffCode: true,
        showOperator: true,
        showInsertime: true,
        showRemark: true,


        tableData: [{
          date: '2016-05-02',
          id: '1',
          name: '王小虎',
          province: 'BC1001',
          city: '合作中',
          address: 'A类',
          zip: ''
        }, {
          id: '2',
          date: '2016-05-04',
          name: '王小虎1',
          province: 'BC1002',
          city: '未合作',
          address: 'A类',
          zip: ''
        }, {
          id: '3',
          date: '2016-05-01',
          name: '王小虎2',
          province: 'BC1003',
          city: '中断',
          address: 'A类',
          zip: ''
        }, {
          id: '4',
          date: '2016-05-03',
          name: '王小虎3',
          province: 'BC1004',
          city: '未合作',
          address: 'A类',
          zip: ''
        }]
        ,
        multipleSelection: []
      }
    },
    components: {
      // 将组建加入组建库
      'send-message': 'url:./send-message.vue',
      'send-weixin': 'url:./send-weixin.vue',
      'send-email': 'url:./send-email.vue',
      'change-customer': 'url:./change-customer.vue',
    },
  }
</script>
